<?php

namespace app\controller;

use app\Controller;
use app\model\City as Model;

class City extends Controller
{
    /**
     * 列表.
     * 
     * @return array
     */
    public function index()
    {
        $result = Model::withSearch(['name', 'pid'], input('get.'))->field(['name'])->paginate([
            'list_rows'=> input('get.pageSize/d', 10),
        ]);
        return json([
            'items' => $result->items(),
            'total' => $result->total()
        ]);
    }
    /**
     * 树型数据.
     * 
     * @return array
     */
    public function tree()
    {
        return json(Model::tree(['value' => 'code'], input('get.level/d', 3)));
    }
}
